package cn.hchaojie.javase.day05;

import java.time.LocalDate;
import java.util.Date;

import org.junit.Test;

public class TestEmployee {
	// 非静态的成员变量，它的值可以独立修改
	@Test
	public void test() {
		Employee e1 = new Employee();
		e1.name = "张三";

		Employee e2 = new Employee();
		e2.name = "李四";
		
		System.out.println(e1.name);
		System.out.println(e2.name);
	}
	
	// 静态变量的特点：属于类级别的，所有的对象共用一份值
	// 修改一个对象的静态成员变量值，会影响另外一个
	@Test
	public void test2() {
		Employee e1 = new Employee();
		Employee e2 = new Employee();
		
		System.out.println(e1.workTime);
		System.out.println(e2.workTime);
		
		e1.workTime.setMonth(1);;

		System.out.println(e1.workTime);
		System.out.println(e2.workTime);
		
		e2.workTime.setMonth(2);
		System.out.println(e1.workTime);
		System.out.println(e2.workTime);
	}
	
	// 类级别和对象级别
	@Test
	public void test3() {
//		Employee e1 = new Employee();
//		System.out.println(e1.workTime);
		
		// 类级别
		System.out.println(Employee.workTime);
		
		// 可以指向另外一个对象
		Employee.workTime = new Date();
		
		// 对象级别的成员变量
		Employee e1 = new Employee();
		System.out.println(e1.name);
		
		System.out.println(Employee.AGE);
		
		// 静态常量不能修改
		// Employee.AGE = 1;
		
		Employee.takeAHoliday();
		
		Employee e = new Employee();
		System.out.println(e.name);
		
		System.out.println(LocalDate.now());
	}
}
